<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //const声明一个只读的常量，一旦声明，常量的值就不能改变
    const PI = 3.14;
    //Uncaught TypeError: Assignment to constant variable.
    //PI = 3.1415;

    //const一旦声明，就必须要初始化，不能留到以后赋值
    //const foo;//'const' declarations must be initialized.

    //const作用域和let相同
    if (true) {
      const MAX = 4;
    }
    console.log(MAX);//Uncaught ReferenceError: MAX is not defined
  </script>
</body>
</html>